{
LANG : PASCAL
PROB : castle
}

program CASTLE;
const
  fi = 'castle.in';
  fo = 'castle.out';
  dx : array[1..4] of integer = (0, -1, 0, 1);
  dy : array[1..4] of integer = (-1, 0, 1, 0);
  max = 50+1;
type
  point = record
            x, y : integer;
          end;
var
  a : array[1..max, 1..max] of byte;
  c : array[0..max, 0..max] of integer;
  S : array[0..max*max] of integer;
  n, m, count, largest, sumlargest : integer;
  h : char;
  p : point;

procedure inp;
var
  i, j : integer;
begin
  read(n, m);
  for i := 1 to m do
    for j := 1 to n do read(a[i, j]);
end;

function getbit(x, y, k : integer) : byte;
begin
  getbit := a[x, y] shr (k-1) and 1;
end;

function BFS(x, y, count : integer) : integer;
var
  q : array[1..max*max] of point;
  i, l, r : integer;
  u, v : point;
begin
  q[1].x := x;
  q[1].y := y;
  l := 1;
  r := 1;
  c[x, y] := count;
  while l <= r do
  begin
    u := q[l];
    inc(l);
    for i := 1 to 4 do
      if getbit(u.x, u.y, i) = 0 then
      begin
        v.x := u.x + dx[i];
        v.y := u.y + dy[i];
        if c[v.x, v.y] = 0 then
        begin
          c[v.x, v.y] := count;
          inc(r);
          q[r] := v;
        end;
      end;
  end;
  BFS := r;
end;

procedure solve1;
var
  i, j : integer;
begin
  fillchar(c, sizeof(c), 0);
  largest := 0;
  count := 0;
  for i := 1 to m do
    for j := 1 to n do
      if c[i, j] = 0 then
      begin
        inc(count);
        S[count] := BFS(i, j, count);
        if S[count] > largest then largest := S[count];
      end;
end;

procedure solve2;
var
  i, j, v : integer;
begin
  sumlargest := 0;
  for j := 1 to n do
    for i := m downto 1 do
    begin
      if c[i, j] <> c[i-1, j] then
      begin
        v := S[c[i, j]] + S[c[i-1, j]];
        if sumlargest < v then
        begin
          sumlargest := v;
          p.x := i;
          p.y := j;
          h := 'N';
        end;
      end;
      if c[i, j] <> c[i, j+1] then
      begin
        v := S[c[i, j]] + S[c[i, j+1]];
        if sumlargest < v then
        begin
          sumlargest := v;
          p.x := i;
          p.y := j;
          h := 'E';
        end;
      end;
    end;
end;

procedure process;
begin
  solve1;
  solve2;
end;

procedure out;
begin
  writeln(count);
  writeln(largest);
  writeln(sumlargest);
  writeln(p.x, ' ', p.y, ' ', h);
end;

begin
  assign(input, fi); reset(input);
  assign(output, fo); rewrite(output);
  inp;
  process;
  out;
  close(output);
  close(input);
end.